/**
 * @Author 12629
 * @Description：
 */
public class Test2 {


    public static void func() {
        func();
    }

    public static int fac(int n) {
        if(n == 1) {
            return 1;
        }

        return n * fac(n-1);
    }


    public static void print(int n) {
        if(n < 10) {
            System.out.println(n);
        }else {
            print(n/10);
            System.out.println(n%10);
        }
    }

    public static int add(int n) {
        if(n == 1) {
            return 1;
        }
        return n + add(n-1);
    }

    public static int fun(int n) {
        if(n < 10) {
            return n;
        }
        return n % 10 + fun(n / 10);
    }

    public static int count = 0;

    public static int fib(int n) {
        if(n == 1 || n == 2) {
            count++;
            return 1;
        }

        return fib(n-1) + fib(n-2);
    }

    public static int fib2(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = -1;

        for (int i = 3; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }

        return f3;
    }

    public static void main(String[] args) {
        //System.out.println(fun(1729));


       /* System.out.println(fib2(1));
        System.out.println(fib2(2));*/
        System.out.println(fib2(41));
        System.out.println("=======");
        System.out.println(fib(41));
        System.out.println(count);

    }

    public static int sum(int a,int b) {
        return a + b;
    }

    public static int sum(int a,int b,int c) {
        return a + b + c;
    }

    public static double sum(double a,double b) {
        return a + b;
    }

    public static void main1(String[] args) {
        int x = 10;
        int y = 20;
        int ret = sum(x,y);
        System.out.println(ret);


        double d = 12.5;
        double e = 14.5;

        double ret2 = sum(d,e);
        System.out.println(ret2);


    }
}
